a tool for shared writing and social publishing
1import { makeRouter } from "../lib"; 2import { push } from "./push"; 3import { createClient } from "@supabase/supabase-js"; 4import { Database } from "supabase/database.types"; 5import { pull } from "./pull"; 6import { getFactsFromHomeLeaflets } from "./getFactsFromHomeLeaflets"; 7import { Vercel } from "@vercel/sdk"; 8import { 9 get_domain_status, 10 get_leaflet_subdomain_status, 11} from "./domain_routes"; 12import { get_leaflet_data } from "./get_leaflet_data"; 13import { get_publication_data } from "./get_publication_data"; 14 15let supabase = createClient<Database>( 16 process.env.NEXT_PUBLIC_SUPABASE_API_URL as string, 17 process.env.SUPABASE_SERVICE_ROLE_KEY as string, 18); 19 20const VERCEL_TOKEN = process.env.VERCEL_TOKEN; 21const vercel = new Vercel({ 22 bearerToken: VERCEL_TOKEN, 23}); 24const Env = { 25 supabase, 26 vercel, 27}; 28export type Env = typeof Env; 29export type Routes = typeof Routes; 30let Routes = [ 31 push, 32 pull, 33 getFactsFromHomeLeaflets, 34 get_domain_status, 35 get_leaflet_subdomain_status, 36 get_leaflet_data, 37 get_publication_data, 38]; 39export async function POST( 40 req: Request, 41 { params }: { params: Promise<{ command: string }> }, 42) { 43 let p = await params; 44 let router = makeRouter(Routes); 45 return router(p.command, req, Env); 46}